/*
 * Copyright (C) 2008+ Spark Zheng
 *
 * src/test/test_log.c
 *
 */

#ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE
#endif
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#ifdef _FILE_OFFSET_BITS
#undef _FILE_OFFSET_BITS
#endif
#define _FILE_OFFSET_BITS	64

#include "log.h"

enum {
	LOG_MAIN = 0,	/* main flow */
	LOG_COMM,	/* dcomm flow */
	LOG_MONT,	/* monitor flow */
	LOG_NUM
};

static dlib_log_args_t log_arg[LOG_NUM] = {
	{LOG_MAIN, "dcache_main.log"},
	{LOG_COMM, "dcache_comm.log"},
	{LOG_MONT, "dcache_mont.log"}
};

int main(int argc, char *argv[])
{

#ifndef _DLIB_LOG_USE_SYSLOG
	if (argc != 3) {
		fprintf(stderr, "Usage: \n" \
				"    test_log_nosyslog IDENT path.\n"
				"    test_log_syslog IDENT.\n");
		return -1;
	}
	
	dlib_log_init(argv[1], argv[2], LOG_NUM, log_arg);
#else
	if (argc != 2) {
		fprintf(stderr, "Usage: test_log_syslog IDENT.\n");
		return -1;
	}
	
	dlib_log_init(argv[1], NULL, 0, NULL);
#endif

	DLOG_DEBUG(LOG_MAIN, "Just a DEBUG test.");
	DLOG_ERR(LOG_MAIN, "Just a ERR test.");
	
	DLOG_EMERG(LOG_COMM, "Just a EMERG test.");
	DLOG_ALERT(LOG_COMM, "Just a ALERT test.");
	DLOG_CRIT(LOG_COMM, "Just a CRIT test.");
	
	DLOG_WARNING(LOG_MONT, "Just a WARNING test.");
	DLOG_NOTICE(LOG_MONT, "Just a NOTICE test.");
	DLOG_INFO(LOG_MONT, "Just a INFO test.");

	while (1) {
		DLOG_ERR(LOG_MAIN, "Just a ERR test.");
	}
	
	dlib_log_exit(LOG_NUM);

	return 0;
}
